<?php

class CronjobController extends GxController {
    /* Weekly class batch schedule */

    public function actionsendMailtoClassExp() {
        $date = date('Y-m-d');        
        $viewPath = Yii::getPathOfAlias('application.components.views.mails');
        $contents = ClassBatch::model()->findAll('start_date <' . "'$date'");
        if (!empty($contents)) {
            foreach ($contents as $content) {              
                $currentBachExp = ClassBatch::model()->find('classes_id=' . $content->classes_id . ' AND start_date>' . "'$date'");
                $currentsession = BatcheSession::model()->find('classes_id=' . $content->classes_id . ' AND date<' . "'$date'");
                $getClaCourseInfo = getClaCourseInfo('Classes', $content->classes_id);
                if (empty($currentBachExp)) {                    
                    Classes::model()->updateByPk($getClaCourseInfo->id, array('class_exp' => SkillConfig::STATUS_ACTIVE));
                }
            }
        }
    }

    public function actionCourseExp() {
        $date = date('Y-m-d');
        $viewPath = Yii::getPathOfAlias('application.components.views.mails');
        $contents = CourseBatche::model()->findAll('date_to < ' . "'$date'");
        if (!empty($contents)) {
            foreach ($contents as $content) {
                $currentBachExp = CourseBatche::model()->find('courses_id=' . $content->courses_id . ' AND date_to >' . "'$date'");
                $getClaCourseInfo = getClaCourseInfo('Courses', $content->courses_id);
                if (empty($currentBachExp)) {                   
                    Courses::model()->updateByPk($getClaCourseInfo->id, array('course_exp' => SkillConfig::STATUS_ACTIVE));
                   
            }
        }
    }}

}

